package com.zxj.netty.common;

import org.apache.commons.lang.StringUtils;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import java.io.IOException;
import java.util.Properties;

public class PropertiesUtils {

    private static Properties prop = null;

    private PropertiesUtils(){}

    static {
        try {
            prop = PropertiesLoaderUtils.loadAllProperties("config.properties");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getProperty(String key) {
        String value = prop.getProperty(key);
        if (StringUtils.isBlank(value)) {
            throw new RuntimeException("config error");
        }
        return value.trim();
    }

}
